﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using LibNiconico.NiconicoApi.Internal;
using LibNiconico.NiconicoApi.Extentions;

namespace LibNiconico.NiconicoApi.PlayerStatus
{
    public sealed partial class NicoPlayerStatus
    {
        public sealed partial class InternalClasses
        {
            /// <summary>
            /// ユーザ情報
            /// </summary>
            public sealed partial class User{
                
                /// <summary>
                /// ユーザ情報内部クラス
                /// </summary>
                public sealed partial class InternalClasses{
                    
                    /// <summary>
                    /// ユーザのツイッター情報
                    /// </summary>
                    public sealed class TwitterInfo
                    {
                        /// <summary>
                        /// ステータス
                        /// </summary>
                        public string Status { get; private set; }

                        /// <summary>
                        /// スクリーン名
                        /// </summary>
                        public string ScreenName { get; private set; }

                        /// <summary>
                        /// フォロワー数
                        /// </summary>
                        public int FollowersCount { get; private set; }

                        /// <summary>
                        /// ビップ判定
                        /// </summary>
                        public bool IsVip { get; private set; }

                        /// <summary>
                        /// プロファイルURL
                        /// </summary>
                        public Uri ProfileImageUrl { get; private set; }

                        /// <summary>
                        /// 不明プロパティ
                        /// </summary>
                        public bool AfterAuth { get; private set; }

                        /// <summary>
                        /// トークン
                        /// </summary>
                        public string TweetToken { get; private set; }

                        internal TwitterInfo() 
                        {
                            this.Status = "";
                            this.ScreenName = "";
                            this.FollowersCount = 0;
                            this.IsVip = false;
                            this.ProfileImageUrl = default(Uri);
                            this.AfterAuth = default(bool);
                            this.TweetToken = "";
                        }

                        internal static TwitterInfo Parse(XElement element)
                        {
                            if (element == null) return null;

                            return XElementExtention.Parse(element, "twitter_info", item =>
                            {
                                return new TwitterInfo
                                {
                                    Status = XElementExtention.GetElementAsString(item, "status"),
                                    ScreenName = XElementExtention.GetElementAsString(item, "screen_name"),
                                    FollowersCount = XElementExtention.GetElementAsInt(item, "folowers_count"),
                                    IsVip = XElementExtention.GetElementAsBool(item, "is_vip"),
                                    ProfileImageUrl = XElementExtention.GetElementAsUri(item, "profile_image_url"),
                                    AfterAuth = XElementExtention.GetElementAsBool(item, "after_auth"),
                                    TweetToken = XElementExtention.GetElementAsString(item, "tweet_token"),

                                };
                            });
                        }
                    }
                }
            }
        }
    }
}
